﻿using System.Collections.Generic;
using Scommesse.Model;
using System.Drawing;
using Scommesse.Utility;

namespace Scommesse.Presenters.Adapters
{
    class TipologiaAdapter : IComposite
    {
        private readonly Tipologia _tipologia;
        private readonly Color _backColor;
        private readonly Color _foreColor;
        private readonly Evento _evento;
        private readonly Font _font;

        public TipologiaAdapter(Tipologia tipologia, Evento evento)
        {
            _evento = evento;
            _tipologia = tipologia;
            _backColor = Color.Empty;
            _foreColor = Color.Empty;
        }


        public TipologiaAdapter(Tipologia tipologia, Evento evento, Font font)
        {
            _evento = evento;
            _tipologia = tipologia;
            _backColor = Color.Empty;
            _foreColor = Color.Empty;
            _font = font;
        }


        public TipologiaAdapter(Tipologia tipologia, Color backColor, Color foreColor,Evento evento, Font font)
        {
            _evento = evento;
            
            _tipologia = tipologia;
            _backColor = backColor;
            _foreColor = foreColor;
            _font = font;
        }

        public Tipologia tipologia
        {
            get { return _tipologia; }
        }

        public Color BackColor
        {
            get { return _backColor; }
        }

        public Color ForeColor
        {
            get { return _foreColor; }
        }

        public IEnumerable<IEntity> SubEntities
        {
            get
            {
                List<IEntity> subEntities = new List<IEntity>();
                foreach(Quota q in _evento.Quote[_tipologia])
                {
                    switch (StringValueAttribute.GetStringValue(q.Valore.GetValore()))
                    {
                        case "1":
                            subEntities.Add(new QuotaAdapter(q, Color.LightSeaGreen, Color.Empty, new Font("Verdana", 8, FontStyle.Regular)));
                            break;
                        case "X":
                            subEntities.Add(new QuotaAdapter(q, Color.GreenYellow, Color.Empty,new Font("Verdana",8,FontStyle.Regular))); 
                            break;
                        case "2":
                            subEntities.Add(new QuotaAdapter(q, Color.LightGreen, Color.Empty, new Font("Verdana", 8, FontStyle.Regular)));
                            break;
                        case "Under":
                            subEntities.Add(new QuotaAdapter(q, Color.LightBlue, Color.Empty, new Font("Verdana", 8, FontStyle.Regular)));
                            break;
                        case "Over":
                            subEntities.Add(new QuotaAdapter(q, Color.LightCyan, Color.Empty, new Font("Verdana", 8, FontStyle.Regular)));
                            break;
                        case "Goal":
                            subEntities.Add(new QuotaAdapter(q, Color.CadetBlue, Color.Empty, new Font("Verdana", 8, FontStyle.Regular)));
                            break;
                        case "NoGoal":
                            subEntities.Add(new QuotaAdapter(q, Color.CornflowerBlue, Color.Empty, new Font("Verdana", 8, FontStyle.Regular)));
                            break;
                    }
                }
                return subEntities;
            }
        }

        public string FullName
        {
            get
            {
                return StringValueAttribute.GetStringValue(_tipologia);
            }
        }

        public Font Font
        {
            get { return _font; }
        }
    }
}
